Skip to content

ci: add typecheck gate to CI workflow - #280

Merged
konowrockis merged 1 commit into
mainfrom
ci/typecheck-gate
Jun 24, 2026
Merged

konowrockis merged 1 commit into
mainfrom
ci/typecheck-gate

Conversation

@claude

@claude claude Bot commented Jun 24, 2026

Copy link
Copy Markdown

Requested by Sebastian Konowrocki · Slack thread

Before: CI ran lint, test, and build on affected projects, but never ran TypeScript type checking. Type errors that didn't break the build (e.g. in spec files or in code paths not exercised by tests) could slip through and only surface later.

After: CI also runs nx affected -t typecheck on every pull request, gating merges on a clean type check across affected projects. It uses the same --parallel and --base/--head PR-SHA inputs as the existing affected steps.

How: Adds a Typecheck step to .github/workflows/ci.yaml, placed after Lint (both are static-analysis gates). The typecheck target already exists in the workspace — it is inferred by the @nx/js/typescript and @nx/vite plugins in nx.json (typecheckTargetName: "typecheck"), so no per-project config is needed. The step mirrors the structure of the surrounding Lint/Test/Build steps exactly.

Not run locally beyond confirming the typecheck target resolves for workspace projects; the step will execute on CI.


Generated by Claude Code

@konowrockis

Copy link
Copy Markdown
Member

@claude jesteś pewny, że build sam w sobie nie robi już typechecka? Jesteś w stanie to sprawdzić?

@claude

claude Bot commented Jun 24, 2026

Copy link
Copy Markdown
Author

Sprawdziłem to empirycznie na czystym checkoucie main (lokalna gałąź, nic nie pushowane) — build nie robi typechecku, więc bramka nie jest redundantna.

Jak działają targety (z nx show project):

  • build = vite build (transpilacja przez esbuild/Rollup — bez sprawdzania typów),
  • typecheck = tsc --build --emitDeclarationOnly (prawdziwy tsc).

Test: wstrzyknąłem czysty błąd typu (nie składniowy) do packages/utils/src/lib/addPrefix.ts:

const _typeErrorProbe: number = "this is a string not a number"

nx run @leancodepl/utils:build:

[vite:dts] ... src/lib/addPrefix.ts:19:9 - error TS2322: Type 'string' is not assignable to type 'number'.
✓ built in 1.48s
NX   Successfully ran target build ...   (exit 0)

Czyli vite-plugin-dts (v4.5.4, skonfigurowany z tsconfigPath: tsconfig.lib.json) wypisuje diagnostykę TS jako log, ale build i tak kończy się sukcesem (exit 0) i emituje dist/. Domyślnie nie przerywa builda na błędach typów.

nx run @leancodepl/utils:typecheck:

src/lib/addPrefix.ts(19,9): error TS2322: Type 'string' is not assignable to type 'number'.
NX   Running target typecheck ... failed   (exit 1)

typecheck łapie błąd i kończy się niezerowym kodem.

Wniosek: build transpiluje/emituje nawet przy błędach typów (tylko je loguje), więc osobna bramka typecheck realnie dokłada pokrycie — szczególnie dla błędów w ścieżkach nieuruchamianych przez testy oraz w plikach spec, które build w ogóle pomija (tsconfig.lib.json wyklucza *.spec.*/*.test.*). PR ma sens, można mergować.

Zmiana testowa była tylko lokalna i została cofnięta.

@konowrockis
konowrockis merged commit cbd3bce into main Jun 24, 2026
1 check passed
@konowrockis
konowrockis deleted the ci/typecheck-gate branch June 24, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants